/**
* @private
* @license	GNU GPLv2
*
* Copyright (C) 2007  Polly Jex.
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
* MA  02110-1301, USA.
*
* @see	http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/

package test {

	/**
	 * @import
	 */
	
	import com.airlogger.AirLoggerDebug;
	import com.kirika.core.CoreStatic;
	import com.kirika.data.ICollection;
	import com.kirika.data.IIterator;
	import com.kirika.data.tda.AbstractCollection;
	import com.kirika.utils.ClassUtil;
	
	/**
	 * Test Abstract Collection
	 * @author	Polly Jex (pollyjex@emc2zen.com.ar)
	 */
	public class TestAbstractCollection extends CoreStatic {
		
		public static function test():void {
			
			AirLoggerDebug.INFO( 'INITIALIZE: ' + ClassUtil.shortName( TestAbstractCollection ) );
			
			var arr:Array = [ 1, 2, 3, 4, 5, 6 ];
			var obj:Object = { a:1, b:2, c:3, d:4, e:5, f:6 };
			
			var ac:ICollection = new AbstractCollection();
			
			AirLoggerDebug.INFO( 'ADD' );
			AirLoggerDebug.DEBUG( 'IS_EMPTY: ' + ac.isEmpty() );
			
			ac.add( 'String' );
			ac.add( 1000 );
			ac.add( arr );
			ac.add( obj );
			
			AirLoggerDebug.DEBUG( 'SIZE: ' + ac.size() );
			AirLoggerDebug.DEBUG( 'TO_ARRAY: ' + ac.toArray().join( ':' ) );
			
			AirLoggerDebug.INFO( 'CONTAINS' );
			
			AirLoggerDebug.DEBUG( 'CONTAINS (String): ' + ac.contains( 'String' ) );
			AirLoggerDebug.DEBUG( 'CONTAINS (string): ' + ac.contains( 'string' ) );
			AirLoggerDebug.DEBUG( 'CONTAINS (10000): ' + ac.contains( 1000 ) );
			AirLoggerDebug.DEBUG( 'CONTAINS (arr): ' + ac.contains( arr ) );
			AirLoggerDebug.DEBUG( 'CONTAINS ([ 1, 2, 3, 4, 5, 6 ]): ' + ac.contains( [ 1, 2, 3, 4, 5, 6 ] ) );
			AirLoggerDebug.DEBUG( 'CONTAINS ([ 1, 2, 3, 4 ]): ' + ac.contains( [ 1, 2, 3, 4 ] ) );
			AirLoggerDebug.DEBUG( 'CONTAINS (obj): ' + ac.contains( obj ) );			
			
			AirLoggerDebug.INFO( 'CONTAINS_ALL' );
			
			AirLoggerDebug.DEBUG( 'CONTAINS_ALL (ac): ' + ac.containsAll( ac ) );
			
			var ac2:ICollection = new AbstractCollection();
			ac2.add( 'String' );
			ac2.add( 1000 );
			ac2.add( arr );
			ac2.add( obj );
			AirLoggerDebug.DEBUG( 'SIZE: ' + ac2.size() );
			AirLoggerDebug.DEBUG( 'TO_ARRAY: ' + ac2.toArray().join( ':' ) );
			
			AirLoggerDebug.DEBUG( 'CONTAINS_ALL (ac2): ' + ac.containsAll( ac2 ) );
			
			ac2.add( 2 );		
			AirLoggerDebug.DEBUG( 'SIZE: ' + ac2.size() );
			AirLoggerDebug.DEBUG( 'TO_ARRAY: ' + ac2.toArray() );
			AirLoggerDebug.DEBUG( 'CONTAINS_ALL (ac2): ' + ac.containsAll( ac2 ) );
			
			AirLoggerDebug.INFO( 'ADD_ALL' );
			
			ac.addAll( ac2 );
			
			AirLoggerDebug.DEBUG( 'SIZE: ' + ac.size() );
			AirLoggerDebug.DEBUG( 'TO_ARRAY: ' + ac.toArray().join( ':' ) );
			
			AirLoggerDebug.INFO( 'REMOVE' );
			
			ac.remove( obj );			
			AirLoggerDebug.DEBUG( 'SIZE: ' + ac.size() );
			AirLoggerDebug.DEBUG( 'TO_ARRAY: ' + ac.toArray().join( ':' ) );
			
			ac.remove( obj );			
			AirLoggerDebug.DEBUG( 'SIZE: ' + ac.size() );
			AirLoggerDebug.DEBUG( 'TO_ARRAY: ' + ac.toArray().join( ':' ) );
			
			AirLoggerDebug.INFO( 'REMOVE_ALL' );
			
			var ac3:ICollection = new AbstractCollection();
			ac3.add( 'String' );
			ac3.add( 1000 );
			
			AirLoggerDebug.DEBUG( 'SIZE (ac): ' + ac.size() );
			AirLoggerDebug.DEBUG( 'TO_ARRAY (ac): ' + ac.toArray().join( ':' ) );
			ac.removeAll( ac3 );			
			AirLoggerDebug.DEBUG( 'SIZE (ac): ' + ac.size() );
			AirLoggerDebug.DEBUG( 'TO_ARRAY (ac): ' + ac.toArray().join( ':' ) );
			
			AirLoggerDebug.DEBUG( 'SIZE (ac2): ' + ac2.size() );
			AirLoggerDebug.DEBUG( 'TO_ARRAY (ac2): ' + ac2.toArray().join( ':' ) );
			ac2.removeAll( ac3 );			
			AirLoggerDebug.DEBUG( 'SIZE (ac2): ' + ac2.size() );
			AirLoggerDebug.DEBUG( 'TO_ARRAY (ac2): ' + ac2.toArray().join( ':' ) );
			
			AirLoggerDebug.INFO( 'EQUALS' );
			
			var ac4:ICollection = new AbstractCollection();
			ac4.add( 'String' );
			ac4.add( 1000 );
			
			var ac5:ICollection = new AbstractCollection();
			ac5.add( 'String' );
			ac5.add( 1000 );
			
			AirLoggerDebug.DEBUG( 'SIZE (ac4): ' + ac4.size() );
			AirLoggerDebug.DEBUG( 'TO_ARRAY (ac4): ' + ac4.toArray().join( ':' ) );
			
			AirLoggerDebug.DEBUG( 'SIZE (ac5): ' + ac5.size() );
			AirLoggerDebug.DEBUG( 'TO_ARRAY (ac5): ' + ac5.toArray().join( ':' ) );
			
			AirLoggerDebug.DEBUG( 'EQUALS ( ac4 == ac5 ): ' + ac4.equals( ac5 ) );
			
			ac5 = ac4;
			AirLoggerDebug.DEBUG( 'EQUALS ( ac4 == ac5 ): ' + ac4.equals( ac5 ) );
			
			AirLoggerDebug.INFO( 'ITERATOR' );
			
			var i:IIterator = ac.iterator();
			
			while( i.hasNext() ){
				i.next();
				AirLoggerDebug.DEBUG( 'ITERATOR (' + i.index() + '): ' + i.value() ); 
				i.remove();
			}
			
			AirLoggerDebug.DEBUG( 'SIZE (ac): ' + ac.size() );
			AirLoggerDebug.DEBUG( 'TO_ARRAY (ac): ' + ac.toArray().join( ':' ) );
			
			AirLoggerDebug.INFO( 'CLEAR' );
			
			AirLoggerDebug.DEBUG( 'SIZE (ac): ' + ac.size() );
			AirLoggerDebug.DEBUG( 'TO_ARRAY (ac): ' + ac.toArray().join( ':' ) );
			
			ac.clear();
			AirLoggerDebug.DEBUG( 'SIZE (ac): ' + ac.size() );
			AirLoggerDebug.DEBUG( 'TO_ARRAY (ac): ' + ac.toArray().join( ':' ) );
			
		}
		
	}
	
}
